﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WorkFlowCore.Workflows;

namespace WorkFlowCore.Plugins
{
    public static class PluginExtension
    {
        public static Plugin ToPlugin(this PluginInfo pluginInfo)
        {
            var plugin = new Plugin(new PluginId(pluginInfo.PluginId_ClassName,pluginInfo.PluginId_Name,pluginInfo.PluginId_EntryFullName), pluginInfo.ConfigMapInfo, pluginInfo.Description, pluginInfo.Id);


            return plugin;
        }

        public static PluginInfo ToPluginInfo(this Plugin plugin, PluginInfo pluginInfo = null)
        {
            if (pluginInfo == null)
                pluginInfo = new PluginInfo(plugin.Id);

            pluginInfo.PluginId_EntryFullName = plugin.PluginId.EntryFullName;
            pluginInfo.PluginId_Name = plugin.PluginId.Name;
            pluginInfo.PluginId_ClassName = plugin.PluginId.ClassName;
            pluginInfo.Description = plugin.Description;
            pluginInfo.ConfigMapInfo = plugin.ConfigMapInfo;
            pluginInfo.Description = plugin.Description;

            return pluginInfo;
        }
    }
}
